package com.lu.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.elasticsearch.search.suggest.completion.context.ContextMapping;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.CompletionContext;
import org.springframework.data.elasticsearch.annotations.CompletionField;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.core.completion.Completion;

import java.util.Date;

/**
 * <p>
 * 文章列表
 * </p>
 *
 * @author lu
 * @since 2019-02-07
 */
@Document(indexName = "sk_article_v1", type = "_doc", createIndex = false)
@Data
public class ArticleEs {

    /**
     * 文章id
     */
    @Id
    private Long id;
    /**
     * 文章创建时间
     */
    @JSONField(name = "create_time")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    /**
     * 文章更新时间
     */
    @JSONField(name = "update_time")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;
    /**
     * 父分类id
     */
    @JSONField(name = "header_pid")
    private Long headerPid;
    /**
     * 子分类id
     */
    @JSONField(name = "header_id")
    private Long headerId;
    /**
     * 作者id
     */
    @JSONField(name = "user_id")
    private Long userId;
    /**
     * 父分类名称
     */
    @JSONField(name = "header_pname")
    private String headerPname;
    /**
     * 子分类名称
     */
    @JSONField(name = "header_name")
    private String headerName;
    /**
     * 文章宣传图片id
     */
    @JSONField(name = "photo_url")
    private String photoUrl;
    /**
     * 标题
     */
    @JSONField(name = "title")
    private String title;
    /**
     * 文章简介
     */
    @JSONField(name = "descript")
    private String descript;
    /**
     * 内容
     */
    @JSONField(name = "content")
    private String content;
    /**
     * 标题
     */
    @CompletionField(
            contexts = {
                    @CompletionContext(name = "author", type = ContextMapping.Type.CATEGORY),
                    @CompletionContext(name = "headerName", type = ContextMapping.Type.CATEGORY),
                    @CompletionContext(name = "headerPname", type = ContextMapping.Type.CATEGORY),
            }
    )
    private Completion titleSuggest;
    /**
     * 文章简介
     */
    @CompletionField(
            contexts = {
                    @CompletionContext(name = "author", type = ContextMapping.Type.CATEGORY),
                    @CompletionContext(name = "headerName", type = ContextMapping.Type.CATEGORY),
                    @CompletionContext(name = "headerPname", type = ContextMapping.Type.CATEGORY),
            }
    )
    private Completion descriptSuggest;
    /**
     * 内容
     */
    @CompletionField(
            contexts = {
                    @CompletionContext(name = "author", type = ContextMapping.Type.CATEGORY),
                    @CompletionContext(name = "headerName", type = ContextMapping.Type.CATEGORY),
                    @CompletionContext(name = "headerPname", type = ContextMapping.Type.CATEGORY),
            }
    )
    private Completion contentSuggest;
    /**
     * 作者
     */
    @JSONField(name = "author")
    private String author;
    /**
     * 授权等级
     */
    @JSONField(name = "auth_level")
    private String authLevel;
    /**
     * 积分
     */
    @JSONField(name = "points")
    private String points;
    /**
     * 浏览量
     */
    @JSONField(name = "views")
    private Integer views;
    /**
     * 点赞数
     */
    @JSONField(name = "thumbs_up")
    private Integer thumbsUp;
    /**
     * 文章状态
     */
    @JSONField(name = "status")
    private Integer status;
    /**
     * 排序
     */
    @JSONField(name = "sort")
    private Integer sort;
}
